/*    */ package com.equipmentmanage.util;
/*    */ 
/*    */ public class PageUtil
/*    */ {
/*    */   public static String getPagation(String targetUrl, int totalNum, int currentPage, int pageSize)
/*    */   {
/* 19 */     int totalPage = totalNum % pageSize == 0 ? totalNum / pageSize : totalNum / pageSize + 1;
/* 20 */     if (totalPage == 0) {
/* 21 */       return "<font color=red>未查询到数据！</font>";
/*    */     }
/* 23 */     StringBuffer pageCode = new StringBuffer();
/* 24 */     pageCode.append("<li><a href='" + targetUrl + "?page=1'>首页</a></li>");
/* 25 */     if (currentPage == 1)
/* 26 */       pageCode.append("<li class='disabled'><a href='#'>上一页</a></li>");
/*    */     else {
/* 28 */       pageCode.append("<li><a href='" + targetUrl + "?page=" + (currentPage - 1) + "'>上一页</a></li>");
/*    */     }
/*    */ 
/* 31 */     for (int i = currentPage - 2; i <= currentPage + 2; i++) {
/* 32 */       if ((i >= 1) && (i <= totalPage))
/*    */       {
/* 35 */         if (i == currentPage)
/* 36 */           pageCode.append("<li class='active'><a href='#'>" + i + "</a></li>");
/*    */         else {
/* 38 */           pageCode.append("<li><a href='" + targetUrl + "?page=" + i + "'>" + i + "</a></li>");
/*    */         }
/*    */       }
/*    */     }
/*    */ 
/* 43 */     if (currentPage == totalPage)
/* 44 */       pageCode.append("<li class='disabled'><a href='#'>下一页</a></li>");
/*    */     else {
/* 46 */       pageCode.append("<li><a href='" + targetUrl + "?page=" + (currentPage + 1) + "'>下一页</a></li>");
/*    */     }
/* 48 */     pageCode.append("<li><a href='" + targetUrl + "?page=" + totalPage + "'>尾页</a></li>");
/* 49 */     return pageCode.toString();
/*    */   }
/*    */ }

/* Location:           C:\Users\arcgis\Desktop\新建文件夹\a0\[www.java1234.com]《SpringMvc设备管理系统》第零讲源码及文档\EquipmentSys\WEB-INF\classes\
 * Qualified Name:     com.java1234.util.PageUtil
 * JD-Core Version:    0.6.1
 */